/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.gis.eemc.web;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;

import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;

import org.richfaces.event.FileUploadEvent;
import org.richfaces.model.UploadedFile;

import net.gis.eemc.domain.Discipline;
import net.gis.eemc.service.DisciplineServiceImpl;

/**
 *
 * @author Sergey
 */
@ManagedBean(name="disciplineBean")
@ViewScoped
public class DisciplineBean {
    private final String ExcerptGos = "ExcerptGos";
    private final String WorkProgram = "WorkProgram";
    private final String LectureSynopsis = "LectureSynopsis";
    private final String GuidelinesCp = "GuidelinesCp";
    private final String GuidelinesLab = "GuidelinesLab";
    private final String DocSamples = "DocSamples";
    private String activeTab = "WorkProgram";

    private boolean autoUpload = false;

    private Discipline discipline;
    private String code;
    private String disciplineName;
    private boolean lectures;
    private boolean practice;
    private boolean labs;
    private boolean quiz;
    private boolean exam;
    private boolean courseProject;
    private boolean test;

    private DisciplineServiceImpl discipSrv = new DisciplineServiceImpl();

    /** Creates a new instance of DisciplineBean */
    public DisciplineBean() {
        try {
            FacesContext context = FacesContext.getCurrentInstance();
            String discipIdStr = context.getExternalContext().getRequestParameterMap().get("id");
            Integer disciplineId = new Integer(discipIdStr);
            discipline = discipSrv.getDiscipline(disciplineId);
            code = String.valueOf(discipline.getCode());
            disciplineName = discipline.getDisciplineName();
            lectures = discipline.isLectures();
            practice = discipline.isPractice();
            labs = discipline.isLabs();
            quiz = discipline.isQuiz();
            exam = discipline.isExam();
            courseProject = discipline.isCourseProject();
            test = discipline.isTest();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public void uploadListener(FileUploadEvent event) throws Exception{
        UploadedFile file = event.getUploadedFile();
        discipSrv.saveExcerptGos(file, discipline);
        System.out.println(file.getName());
    }

    public String getActiveTab() {
        return activeTab;
    }

    public void setActiveTab(String activeTab) {
        this.activeTab = activeTab;
    }

    public boolean isAutoUpload() {
        return autoUpload;
    }

    public void setAutoUpload(boolean autoUpload) {
        this.autoUpload = autoUpload;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public boolean isCourseProject() {
        return courseProject;
    }

    public void setCourseProject(boolean courseProject) {
        this.courseProject = courseProject;
    }

    public String getDisciplineName() {
        return disciplineName;
    }

    public void setDisciplineName(String disciplineName) {
        this.disciplineName = disciplineName;
    }

    public boolean isExam() {
        return exam;
    }

    public void setExam(boolean exam) {
        this.exam = exam;
    }

    public boolean isLabs() {
        return labs;
    }

    public void setLabs(boolean labs) {
        this.labs = labs;
    }

    public boolean isLectures() {
        return lectures;
    }

    public void setLectures(boolean lectures) {
        this.lectures = lectures;
    }

    public boolean isPractice() {
        return practice;
    }

    public void setPractice(boolean practice) {
        this.practice = practice;
    }

    public boolean isQuiz() {
        return quiz;
    }

    public void setQuiz(boolean quiz) {
        this.quiz = quiz;
    }

    public boolean isTest() {
        return test;
    }

    public void setTest(boolean test) {
        this.test = test;
    }

    public String getDocSamples() {
        return DocSamples;
    }

    public String getExcerptGos() {
        return ExcerptGos;
    }

    public String getGuidelinesCp() {
        return GuidelinesCp;
    }

    public String getGuidelinesLab() {
        return GuidelinesLab;
    }

    public String getLectureSynopsis() {
        return LectureSynopsis;
    }

    public String getWorkProgram() {
        return WorkProgram;
    }
    


    
}
